﻿using Core.Extension;
using UnityEngine;

namespace Core.Mgr
{
    public class PluginMgr : SingletonMono<PluginMgr>
    {
        private AndroidJavaObject _androidJavaObject = null;

        public AndroidJavaObject AndroidJavaObject
        {
            get
            {
                if (_androidJavaObject == null)
                {
                    _androidJavaObject =
                        new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>(
                            "currentActivity");
                }

                return _androidJavaObject;
            }
        }

        /// 震动
        public void VibratorOnce(long millisecond, int amplitude)
        {
//             amplitude = Mathf.Clamp(amplitude, 1, 255);
// #if UNITY_EDITOR || DEVELOP
//
// #elif UNITY_IOS
//             CommonUtils.Vibrator(millisecond);
// #elif UNITY_ANDROID
//             AndroidJavaObject.CallStatic("vibratorOnce", AndroidManager.GetContext(), millisecond,amplitude);
// #endif
        }

        public void VibratorWave(long millisecond, int amplitude)
        {
            Debug.Log("开始连续震动~");
//             amplitude = Mathf.Clamp(amplitude, 1, 255);
// #if UNITY_EDITOR || DEVELOP
//
// #elif UNITY_IOS
//             CommonUtils.Vibrator(millisecond);
// #elif UNITY_ANDROID
//             AndroidJavaObject.CallStatic("vibratorWave", AndroidManager.GetContext(), millisecond,amplitude);
// #endif
        }

        /// 停止波形震动
        public void StopWaveVibrator()
        {
            Debug.Log("Unity : StopWaveVibrator");
// #if UNITY_EDITOR || DEVELOP
//
// #elif UNITY_ANDROID
//             AndroidJavaObject.CallStatic("StopVibratorWave", AndroidManager.GetContext());
// #endif
        }


        /// 开始App评论
        public void StartAppReview()
        {
//             if (!ConfigMgr.Ins.ConfigModel.popupAppReview) return;
//             if (PlayerPrefs.HasKey("IsPopupAppReview")) return;
//             PlayerPrefs.SetInt("IsPopupAppReview", 1);
// #if UNITY_EDITOR
//
// #elif UNITY_IOS
//             CommonUtils.ShowAppleSystemCommentDialog();
// #elif UNITY_ANDROID
//             AndroidJavaObject.Call("startAppReview");
// #endif
//             Debug.Log("Unity Run StartAppReview");
        }
    }
}